<?php
namespace Home\Controller;

use Think\Controller;

// 需要登录才能访问的
class SignInAgenController extends BaseController {

    Public function _initialize(){

        parent::_initialize();

        // 没有登录
        $account = $this->getagenAccount();
        if(empty($account)){
            if (IS_AJAX){
                exit( $this->ajaxLoginError("请登录"));
            }else{
                $this->redirect('home/index/login');
            }

        }
    }

    // 获取账号信息
    function getagenAccount(){
        // 获取token
       $agen= $this->get('agen');
        if(empty($agen)){
            exit( $this->ajaxLoginError("请登录"));
        }
        return $agen;
    }

    // 获取账号ID
    function getagenAccountId(){
        return $this->getagenAccount()['id'];
    }
}